<template>
   <div class="app-container">


    <el-form inline ref="memberVoForm" :model="memberVoForm" label-width="80px">
      <el-form-item label="会员名称">
        <el-input v-model="memberVoForm.nickname"></el-input>
      </el-form-item>
      <el-form-item label="手机号">
        <el-input v-model="memberVoForm.mobile"></el-input>
      </el-form-item>

      <el-form-item>
        <el-button type="primary" @click="onSubmit">搜索</el-button>
        <el-button @click="reset">置空</el-button>
      </el-form-item>
    </el-form>

    <el-table
      v-loading="listLoading"
      :data="list"
      element-loading-text="Loading"
      border
      fit
      highlight-current-row>
      <el-table-column align="center" label="序号" width="95">
        <template slot-scope="scope">
          {{ scope.$index +1}}
        </template>
      </el-table-column>
      <el-table-column label="会员名称">
        <template slot-scope="scope">
          {{ scope.row.nickname }}
        </template>
      </el-table-column>
      <el-table-column label="性别"   align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.sex ==1 ? '女':'男' }}</span>
        </template>
      </el-table-column>
      <el-table-column label="年龄"   align="center">
        <template slot-scope="scope">
          {{ scope.row.age }}
        </template>
      </el-table-column>
      <el-table-column label="手机号"   align="center">
        <template slot-scope="scope">
          {{ scope.row.mobile }}
        </template>
      </el-table-column>

      <el-table-column label="是否禁用"   align="center">
        <template slot-scope="scope">
          <span>{{ scope.row.isDisabled ==1 ? '已禁用':'未禁用' }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"   label="添加时间" >
        <template slot-scope="scope">
          <i class="el-icon-time"/>
          <span>{{ scope.row.eduCreate }}</span>
        </template>
      </el-table-column>

      <el-table-column align="center"  label="修改时间"  >
        <template slot-scope="scope">
          <i class="el-icon-time"/>
          <span>{{ scope.row.eduModified }}</span>
        </template>
      </el-table-column>
      <el-table-column align="center"  label="操作"  >
        <template slot-scope="scope">
          <el-button type="primary" @click="handleClick(scope.row.id)" size="mini">拉黑</el-button>
        </template>

      </el-table-column>

    </el-table>
    <div class="block">
      <el-pagination
        @current-change="handleCurrentChange"
        :current-page.sync="page.current"
        :page-size="page.size"
        layout="total, prev, pager, next"
        :total="page.total">
      </el-pagination>
    </div>

  </div>
</template>

<script>



import {getList,getPut} from "../../api/member";
export default {

  data() {
    return {
      list: null,
      listLoading: true,
      page: {
          current: 1,
          total: 0,
          size: 2
        },
      memberVoForm:{
        nickname:'',
        mobile:'',
      }

    }
  },
  created() {
    this.fetchData()
  },
  methods: {
    handleClick(id) {
      getPut(id).then(resp=>{
        console.log("禁用成功");
        this.getPage()
      })
    },

    handleCurrentChange(val) {
        console.log(`当前页: ${val}`)
        this.page.current=val
        this.getPage()

    },
    reset(){
      this.memberVoForm={
        nickname:'',
          mobile:'',
      }
      this.getPage()
    },
    onSubmit() {
      console.log('submit!');
      this.getPage()
    },
    getPage(){
      getList(this.page.current,this.memberVoForm).then(response => {
        this.list = response.data.records
        this.page = response.data
        this.listLoading = false
      })
    },
    fetchData() {
      this.listLoading = true
      this.getPage()
    }
  }
}

</script>

<style>

</style>
